package com.amumu.drama.common.constant;

import com.google.common.collect.Maps;
import lombok.Getter;

import java.util.Arrays;
import java.util.Map;

/**
 * 模板类型
 */
@Getter
public enum ProductTemplateTypeEnum {
    /* 支付类型 */
    DIRECT("DIRECT", "直充"),
    CUSTOM("CUSTOM", "自定义"),
    ;

    /** 索引 */
    private static final Map<String, ProductTemplateTypeEnum> KEY_UN_INDEX = Maps.uniqueIndex(Arrays.asList(values()), ProductTemplateTypeEnum::getCode);
    /** code url */
    private String code;
    /** 描述 */
    private String name;

    ProductTemplateTypeEnum(String code, String name) {
        this.code = code;
        this.name = name;
    }

    public static ProductTemplateTypeEnum getByCode(String code) {
        return KEY_UN_INDEX.getOrDefault(code, null);
    }


}
